<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm"  :inline="true" v-show="showSearch">
      <el-form-item label="库房编号" prop="storecode">
        <el-input v-model="queryParams.storecode" placeholder="请输入库房编号" clearable style="width: 240px" maxlength="30"></el-input>
      </el-form-item>
      <el-form-item label="库房名称" prop="storeName">
        <el-input v-model="queryParams.storeName" placeholder="请输入库房名称" clearable style="width: 240px" maxlength="30"></el-input>
      </el-form-item>
      <el-form-item label="题名" prop="title">
        <el-input v-model="queryParams.title" placeholder="请输入题名" clearable style="width: 240px" maxlength="30"></el-input>
      </el-form-item>
      <el-form-item label="档号" prop="dh">
        <el-input v-model="queryParams.dh" placeholder="请输入档号" clearable style="width: 240px" maxlength="30"></el-input>
      </el-form-item>
      <el-form-item label="出/入库时间" prop="dateRange">
        <el-date-picker v-model="dateRange" value-format="yyyy-MM-dd" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" clearable style="width: 240px">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button style="margin-left: 20px" type="primary" icon="el-icon-search"  @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh"  @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8" ref="refbut">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="dataList" :height="tableHeight">
      <el-table-column label="序号" type="index" :index="table_index" width="55" align="center" prop="id"/>
      <el-table-column label="库房编号" prop="storecode" align="center" />
      <el-table-column label="库房名称" prop="storeName" align="center" />
      <el-table-column label="题名" prop="title" align="center" />
      <el-table-column label="档号" prop="dh" align="center" />
      <el-table-column label="出/入库" prop="type" align="center" />
      <el-table-column label="出库/入库时间" prop="crkqr" align="center" />
      <el-table-column label="出库原因" prop="ckyy" align="center">
        <template slot-scope="scope">
          <span v-for="(i, idx) in dict.type.OUTBOUND_REASON" :key="idx">
            {{ scope.row.ckyy == i.value ? i.label : '' }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="出库/入库人员" prop="crkgzry" align="center" />
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />


  </div>
</template>

<script>
import estimateTableHeight from '@/mixins/estimateTableHeight'
import {outIntLogs} from "@/api/archive/warehouseManagement/entryExitRecord";
export default {
  name: "index",
  mixins: [estimateTableHeight], // 混入方法
  archive_Dicts: ['OUTBOUND_REASON'],
  data() {
    return {
      // 遮罩层
      loading: false,
      // 查询参数
      queryParams: {
        pageNum:1,
        pageSize:10,
        storecode: undefined,
        storeName: undefined,
        title: undefined,
        dh: undefined,
      },
      dateRange: [],
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      dataList: [],
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true
    }
  },
  created() {
    this.getList()
  },
  methods: {
    table_index(index){
      return (this.queryParams.pageNum-1) * this.queryParams.pageSize + index + 1;
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      if(this.dateRange != null) {
        if (this.dateRange.length != 0) {
          this.queryParams.crkqr = this.dateRange[0].toString()
          this.queryParams.edCrkqr = this.dateRange[1].toString()
        }
      } else {
        this.queryParams.crkqr = ""
        this.queryParams.edCrkqr = ""
      }
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = null
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 获取表格数据
    getList() {
      this.loading = true
      outIntLogs(this.queryParams).then(response=>{
        this.loading = false
        this.dataList = response.rows
        this.total = response.total
      })
    }
  }
}
</script>

<style scoped>

</style>
